package pso;

import java.util.Random;

public class RandomPointGenerator implements PointGenerator {
	private Random r = new	java.util.Random();
	private Point lowerBound, upperBound;
	
	
	public RandomPointGenerator(Point lowerBound, Point upperBound){
		this.lowerBound = lowerBound;
		this.upperBound = upperBound;
	}
	
	
	public Point nextPoint() {
		double[] coordinates = new double[lowerBound.getDimension()]; 
		for(int i = 0; i < lowerBound.getDimension(); i++){
			double factor = upperBound.getCoordinates()[i] - lowerBound.getCoordinates()[i];
			coordinates[i] = upperBound.getCoordinates()[i] - factor * r.nextDouble();
		}
		return new Point(coordinates);
	}

}
